home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03020204.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  3.8 KB  |  57 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Put Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03020204"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:to-be-embedded Eid="put" xmlns:help="http://openoffice.org/2000/help"><a name="put"/>
  14.   <p class="Head1"><help:link Id="66627">Put Statement [Runtime]</help:link></p>
  15.   <p class="Paragraph">Writes a record to a relative file or a sequence of bytes to a binary file.</p>
  16.   </help:to-be-embedded>
  17.   <p class="Paragraph">See also: <help:link Id="66578" Eid="get" xmlns:help="http://openoffice.org/2000/help">Get</help:link> statement</p>
  18.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  19.   <p class="Paragraph">Put [#] FileNumber As Integer, [position], Variable <help:key-word value="Put" tag="kw66627_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  20.   <p class="Paragraph"><span class="T1">Parameter</span>:</p>
  21.   <p class="Paragraph">FileNumber: Any integer expression that defines the file to write into.</p>
  22.   <p class="Paragraph">Position: For relative files (random access files) the number of the record to be written.</p>
  23.   <p class="Paragraph">For binary files (binary access) the byte position in the file at which to begin writing.</p>
  24.   <p class="Paragraph">Variable: Name of the variable to write to the file.</p>
  25.   <p class="Paragraph">Note for relative files: If the contents of this variable do not match the length of a record specified in the <span class="T1">Len</span> <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>clause of the <span class="T1">Open</span> statement, the space from the end of the new written data to the next record is padded with the existing data in the file.</p>
  26.   <p class="Paragraph">Note for binary files: The contents of the variables is written to the specified position, and the file pointer is set directly after the last byte, without any space between records.</p>
  27.   <p class="P2">Example:</p>
  28.   <p class="PropText">Sub ExampleRandomAccess</p>
  29.   <p class="PropText">Dim iNumber As Integer</p>
  30.   <p class="PropText">Dim sText As Variant REM Must be a variant type</p>
  31.   <p class="PropText">Dim aFile As String</p>
  32.   <p class="PropText">aFile = "c:\data.txt"</p>
  33.   <p class="PropText"/>
  34.   <p class="PropText">iNumber = Freefile</p>
  35.   <p class="PropText">Open aFile For Random As #iNumber Len=32</p>
  36.   <p class="PropText">Seek #iNumber,1 <text:s text:c="2" xmlns:text="http://openoffice.org/2000/text"/>REM Position to start writing</p>
  37.   <p class="PropText">Put #iNumber,, "This is the first line of text" <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>REM Fill line with text</p>
  38.   <p class="PropText">Put #iNumber,, "This is the second line of text"</p>
  39.   <p class="PropText">Put #iNumber,, "This is the third line of text"</p>
  40.   <p class="PropText">Seek #iNumber,2</p>
  41.   <p class="PropText">Get #iNumber,,sText</p>
  42.   <p class="PropText">Print sText</p>
  43.   <p class="PropText">Close #iNumber</p>
  44.   <p class="PropText"/>
  45.   <p class="PropText">iNumber = Freefile</p>
  46.   <p class="PropText">Open aFile For Random As #iNumber Len=32</p>
  47.   <p class="PropText">Get #iNumber,2,sText</p>
  48.   <p class="PropText">Put #iNumber,,"This is new text"</p>
  49.   <p class="PropText">Get #iNumber,1,sText</p>
  50.   <p class="PropText">Get #iNumber,2,sText</p>
  51.   <p class="PropText">Put #iNumber,20,"This is the text in record 20"</p>
  52.   <p class="PropText">Print Lof(#iNumber)</p>
  53.   <p class="PropText">Close #iNumber</p>
  54.   <p class="PropText"/>
  55.   <p class="PropText">end sub</p>
  56.   <p class="PropText"/>
  57.  </body></html>